package com.bigerdranch.android.geoquiz;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

/**
 * 显示用户回答的正确，错误等信息
 */
public class ExitActivity extends AppCompatActivity {

    private TextView mCountTextView;
    private Button mRestartButton;
    private Button mExitButton;

    public static final String EXTRA_ANSWER_COUNT_INFO = "com.bignerdranch.android.geoquiz.true_false_acc";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exit);

        //获得intent引用
        Intent intent = getIntent();
        //根据KEY取出value
        String CountInfo = intent.getStringExtra(EXTRA_ANSWER_COUNT_INFO);
        //获得文本框引用，设置文字
        mCountTextView = findViewById(R.id.mCountTextView);
        mCountTextView.setText(CountInfo);

        mRestartButton =  findViewById(R.id.btnRestart);
        mExitButton =  findViewById(R.id.btnExit);

        // 重新开始
        mRestartButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
                startActivity(new Intent(ExitActivity.this, CheatActivity.class));
            }
        });

        // 结束程序
        mExitButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
}